import axios from "@/utils/request.js";

/**
 * 添加训练排名
 * @param trainRankForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankAddService = (trainRankForm) => {
  return axios.post("/trainRankInfo/add",trainRankForm)
}

/**
 * 添加训练排名
 * @param trainRankForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankAddBatchService = (trainRankForm) => {
  return axios.post("/trainRankInfo/addBatch",trainRankForm)
}

/**
 * 分页查询训练排名
 * @param currentPage
 * @param pageSize
 * @param trainRankNameInput
 * @param authorInput
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankSelectService = (currentPage,pageSize,trainRankNameFuzzy,trainRankTime,beginTime,endTime) => {
  return axios.get("/trainRankInfo/loadDataList",{params:{
    currentPage,pageSize,trainRankNameFuzzy,trainRankTime,beginTime,endTime
    }})
}

/**
 * 开启/关闭训练
 * @param trainRankId
 * @param opentrainRank
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankOpenOrCloseService = (trainRankId,opentrainRank) => {
  return axios.put("/trainRank/changeOpentrainRank",{trainRankId,opentrainRank})
}

/**
 * 根据id删除训练
 * @param rankId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankDeleteService = (rankId) => {
  return axios.delete("/trainRankInfo/deleteTrainRankInfoByRankId",{params:{
    rankId
  }})
}

/**
 * 根据训练id查询题目数组
 * @param titleId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankSelectTitlesByTitleIdService = (trainRankId) => {
  return axios.get("/trainRank/selectTitlesBytrainRankId",{params:{trainRankId: trainRankId}})
}

/**
 * 根据训练id查询题目id数组和题目名称数组
 * @param trainRankId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankSelectTitleIdsAndNamesService = (trainRankId) => {
  return axios.get("/trainRank/selectTitlesArrBytrainRankId",{params:{trainRankId: trainRankId}})
}

/**
 * 修改训练排名
 * @param trainRankForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankModifyService = (trainRankForm) => {
  return axios.put("/trainRankInfo/updateTrainRankInfoByRankId",trainRankForm)
}

/**
 * 查询所有训练次数 （用于echarts图渲染）
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainRankCountAllService = () => {
  return axios.get("/trainRank/countAll")
}
